s="中国"
print(s.encode("utf8"))  # 3个字节
print(s.encode("gbk"))   # 2个字节
# 解码  decode（）
bs = b'\xe4\xb8\xad\xe5\x9b\xbd'
bg = b'\xd6\xd0\xb9\xfa'
print(bs.decode("utf-8"))
print(bg.decode("gbk"))
# print(bs.decode("gbk"))  # 用什么编码就要用什么解码 UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 2: illegal multibyte sequence
print(bs.decode("utf-8").encode("gbk"))  # 结果：b'\xd6\xd0\xb9\xfa'